<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
	/**
	 * 
	 * @var Zend_View
	 */
	private $view;
	
	/**
	 * 
	 * init autoload the resources
	 */
	public function _initAutoloadPackage() {
		$autoloader = Zend_Loader_Autoloader::getInstance();		
		$autoloader->registerNamespace('App_');
		$autoloader->registerNamespace('Doctrine');
	}
	
	/**
	 * 
	 */
	public function _initViewResource() 
	{
		$this->bootstrap('view');
		$this->view = $this->getResource('view');
	}
	
	/**
	 * config zend navigation
	 */
	public function _initNavigation() 
	{
		if ($this->view === null) {
		    return;
		}
		$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml','menu-admin');
		$navigation = new Zend_Navigation($config);
		Zend_Registry::set('navigation', $navigation);
		$this->view->navigation($navigation); 
	}
	
	/**
	 * Register plugins
	 */
	public function _initRegisterPlugin() {
		$frontController = Zend_Controller_Front::getInstance();
		// register plugin view setup
       if (!$frontController->hasPlugin('App_Controller_Plugin_Acl')) {
       		$frontController->registerPlugin(new App_Controller_Plugin_Acl(), 1);
       } 
//         if (!$frontController->hasPlugin('App_Controller_Plugin_RouterSetup')) {
//         	$frontController->registerPlugin( new App_Controller_Plugin_RouterSetup(), 2);
//         } 
		if (!$frontController->hasPlugin('App_Controller_Plugin_ViewSetup')) {
        	$frontController->registerPlugin( new App_Controller_Plugin_ViewSetup(), 3);
        } 
		
	}
	
	/**
	 * Register Action Helper
	 */
	public function _initActionHelper() {
		$_messenger = new App_Controller_Action_Helper_Messenger();
		Zend_Controller_Action_HelperBroker::addHelper($_messenger);
		Zend_Controller_Action_HelperBroker::addPrefix("App_Controller_Action_Helper");
	}
}

